package com.example.controller;

import com.example.threadPool.ThreadPools;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.concurrent.TimeUnit;


@SuppressWarnings("ALL")
@RestController
@RequestMapping("/test")
public class TestInterfaceController {

    
    @GetMapping("/v1")
    public Object test1(){
        HashMap<String, String> map = new HashMap<>(1);
        map.put("test1","测试1");
        return map;
    }

    @GetMapping("/v2")
    public void test2(){
        for (int i = 0; i < 100; i++) {
            final int param = i;
            ThreadPools.demoExcutor.submit(()->{
                System.out.println(Thread.currentThread().getName()+"执行参数："+param);
                try {
                    Thread.sleep(2000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            });
        }
    }
}
